﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
<Serializable()> Public Class RectableGroups
   
    Private m_RectableAerageingTime(-1) As RectableAerageingTime
    Private m_PeriodNameAndData As New NameAndData '用于储存长期浓度的文件名及内容
    Private m_PeriodMaxTalbeResult As New MaxTalbeResult '用于储存期间平均前n最大值的计算结果
    

    ''' <summary>
    ''' 不同的平均时间的集合
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property RectableAerageingTime() As RectableAerageingTime()
        Get
            Return Me.m_RectableAerageingTime
        End Get
        Set(ByVal value As RectableAerageingTime())
            Me.m_RectableAerageingTime = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存期间平均所有点前n最大值的计算结果
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property PeriodMaxTalbeResult() As MaxTalbeResult
        Get
            Return m_PeriodMaxTalbeResult
        End Get
        Set(ByVal value As MaxTalbeResult)
            m_PeriodMaxTalbeResult = value
        End Set
    End Property


    ''' <summary>
    ''' 用于储存期间平均的计算结果的文件名称和内容的字符串
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property PeriodNameAndData() As NameAndData
        Get
            Return Me.m_PeriodNameAndData
        End Get
        Set(ByVal value As NameAndData)
            Me.m_PeriodNameAndData = value
        End Set
    End Property

    ''' <summary>
    '''
    ''' </summary>
    ''' <param name="strAERMODOUT"> 用于分析的Aermod的输出文件</param>
    ''' <param name="Group">当前污染源分组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">是否考虑沉积作用</param>
    ''' <param name="AerageTime">平均时间</param>
    ''' <param name="MaxCon">前MaxCon个高值</param>
    ''' <param name="version">用于分析的Aermod的输出文件的版本</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetData(ByVal strAERMODOUT As String(), ByVal Group As Group, ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal AerageTime As AerageingTime, ByVal MaxCon As Integer, ByVal version As String)
        If m_PeriodNameAndData.GetPeriodDate(strAERMODOUT, Receptor, IsDep, Group.GroupID, Group.SourceCount, version) = False Then
            Return False
        End If
        If AerageTime.H1 = True Then

            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            '计算各点高值
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST  1-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H2 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST  2-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H3 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime

            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST  3-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H4 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime

            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST  4-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H6 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST  6-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H8 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST  8-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H12 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST 12-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.H24 = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST 24-HR", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        If AerageTime.Month = True Then
            ReDim Preserve m_RectableAerageingTime(m_RectableAerageingTime.Length)
            m_RectableAerageingTime(m_RectableAerageingTime.Length - 1) = New RectableAerageingTime
            If m_RectableAerageingTime(m_RectableAerageingTime.Length - 1).GetDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, "HIGHEST MONTH", MaxCon, Group.GroupID, Group.SourceCount, version) = False Then
                Return False
            End If
        End If
        Return True
    End Function


End Class
